package Server;

import java.io.*;
import java.net.*;

class SocketServer 
{
	ServerSocket Server;
	static Socket connected;
	
   public SocketServer() throws IOException{
	   Server = new ServerSocket (5000);
	   
	   connected = Server.accept();
       System.out.println( " THE CLIENT"+" "+
       connected.getInetAddress() +":"+connected.getPort()+" IS CONNECTED ");
       
       System.out.println("SEND(Type Q or q to Quit):");
   }
   
	
   public void serve(String toClient) throws Exception
      {
                  
            PrintWriter outToClient =
               new PrintWriter(
                  connected.getOutputStream(),true);
            	
            	if ( toClient.equals ("q") || toClient.equals("Q") )
            	{
            		outToClient.println(toClient);
            		connected.close();
            	}
            	else
            	{
            		outToClient.println(toClient);
                }	       
      }
}
